package java0413;

//
////class Test1 {
////    static void fun2() {
////        System.out.println("test1");
////    }
////}
////
////class Test extends Test1{
////    static void fun() {
////        System.out.println("test");
////    }
////    void fun1() {
////        fun();
////    }
////    void fun3() {
////        fun2();
////    }
////}
//
//public class Main {
//
//    public static void main(String[] args) {
////        String string1 = "hello";
////        String string2 = "he" + new String("llo");
////        System.out.println(string1 == string2);
//        // Hash 的 map 和 set 都可以插入 null 作为 key,
//        // Tree 的 map 和 set 都不可以插入 null 作为 key.
//        // HashMap 可以插入 null 为 key, TreeMap不可以
////        Map<Integer, Integer> map1 = new HashMap<>();
////        System.out.println(map1.put(null, 1));
////        Map<Integer, Integer> map2 = new TreeMap<>();
////        map2.put(null, 1);
////        //
////        Set<Integer> set1 = new HashSet<>();
////        System.out.println(set1.add(null));
////        Set<Integer> set2 = new TreeSet<>();
////        System.out.println(set2.add(null));
////        Test test = new Test();
////        test.fun3();
//    }
//}

import java.util.Scanner;
import java.util.Stack;

// 牛客:字符串中找出连续最长数字串
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String string = scanner.nextLine();
            String ret = func(string);
            System.out.println(ret);
        }
    }

    private static String func(String string) {
        Stack<Integer> stack = new Stack<>();
        boolean flag = false;
        for (int i = 0; i < string.length(); i++) {
            if (flag == false && isNumber(string.charAt(i))) {
                stack.push(i);
                flag = true;
                continue;
            }
            if (flag == true && !isNumber(string.charAt(i))) {
                stack.push(i);
                flag = false;
                continue;
            }
        }
        if (flag == true && isNumber(string.charAt(string.length() - 1))) {
            stack.push(string.length());
        }
        if (stack.isEmpty() == true) {
            return "";
        }
        int max = 0;
        int[] maxIndex = new int[2];
        while (stack.isEmpty() == false) {
            int right = stack.pop();
            int left = stack.pop();
            if (max < right - left) {
                max = right - left;
                maxIndex[1] = right;
                maxIndex[0] = left;
            }
        }
        return string.substring(maxIndex[0], maxIndex[1]);
    }


    private static boolean isNumber(char c) {
        if (c >= '0' && c <= '9') {
            return true;
        }
        return false;
    }
}
